﻿@{
    ViewBag.Title = "title";
    Layout = "~/Views/Shared/_Layout.cshtml";
    //Layout = null;
}
@section head{
    
    
    }
 @section scripts{
    

  
}

 
 

<div style=" padding:100px;">
    <a id="J_UploaderBtn" href="#upload"> 选择要上传的文件 </a>
    <ul id="J_UploaderQueue"></ul>
</div>

<script src="/Content/js/kissy/kissy.js" type="text/javascript"></script>
<script type="text/javascript">
    KISSY.config({ packages: [{ name: "gallery", path: "/Content/js/kissy/", charset: "utf-8" }] });
    KISSY.use('gallery/form/1.3/uploader/index', function (S, RenderUploader) {
        var ru = new RenderUploader('#J_UploaderBtn', '#J_UploaderQueue', {
            serverConfig: { //服务器端配置
                action: "/api/mms/test/postfile"//处理上传的服务器端脚本路径
            },
            name: "Filedata",// 文件域
            urlsInputName: "fileUrls" //用于放服务器端返回的url的隐藏域
        });

        ru.on("init", function (ev) {
            var uploader = ev.uploader;
            uploader.on('render', function (ev) {
                alert('上传组件准备就绪！');
            });
            uploader.on('select', function (ev) {
                var files = ev.files;
                alert('选择了' + files.length + '个文件');
            });
            uploader.on('start', function (ev) {
                var index = ev.index, file = ev.file;
                alert('开始上传,文件名：' + file.name + '，队列索引为：' + index);
            });
            uploader.on('progress', function (ev) {
                var file = ev.file, loaded = ev.loaded, total = ev.total;
                alert('正在上传,文件名：' + file.name + '，大小：' + total + '，已经上传：' + loaded);
            });
            uploader.on('success', function (ev) {
                var index = ev.index, file = ev.file;
                //服务器端返回的结果集
                var result = ev.result;
                alert('上传成功,服务器端返回上传方式：' + result.type);
            });
            uploader.on('complete', function (ev) {
                var index = ev.index, file = ev.file;
                //服务器端返回的结果集
                var result = ev.result;
                alert('上传结束,服务器端返回上传状态：' + result.status);
            });
            uploader.on('error', function (ev) {
                var index = ev.index, file = ev.file;
                //服务器端返回的结果集
                var result = ev.result;
                alert('上传失败,错误消息为：' + result.msg);
            });
            uploader.on('add', function (ev) {
                var queue = ev.queue;
                var file = ev.file;
                alert('队列添加文件！文件名为：' + file.name);
            });
            uploader.on('remove', function (ev) {
                var queue = ev.queue;
                alert('队列删除文件！文件索引值：' + ev.index);
                alert('队列中的文件数为：' + queue.get('files').length);
            });
        })
    });
</script>
